home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / xgopher.1.3 / sc_dir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-08  |  2.7 KB  |  132 lines

  1. /* sc_dir.c
  2.    gopher item subclass procedures for directories */
  3.  
  4.      /*---------------------------------------------------------------*/
  5.      /* Xgopher        version 1.3     08 April 1993                  */
  6.      /*                version 1.2     20 November 1992               */
  7.      /*                version 1.1     20 April 1992                  */
  8.      /*                version 1.0     04 March 1992                  */
  9.      /* X window system client for the University of Minnesota        */
  10.      /*                                Internet Gopher System.        */
  11.      /* Allan Tuchman, University of Illinois at Urbana-Champaign     */
  12.      /*                Computing and Communications Services Office   */
  13.      /* Copyright 1992, 1993 by                                       */
  14.      /*           the Board of Trustees of the University of Illinois */
  15.      /* Permission is granted to freely copy and redistribute this    */
  16.      /* software with the copyright notice intact.                    */
  17.      /*---------------------------------------------------------------*/
  18.  
  19. #include "conf.h"
  20. #include "globals.h"
  21. #include "gopher.h"
  22. #include "util.h"
  23. #include "status.h"
  24. #include "appres.h"
  25. #include "item.h"
  26. #include "dir.h"
  27. #include "dirList.h"
  28. #include "sc_dir.h"
  29. #include "sc_dirP.h"
  30.  
  31.  
  32.  
  33. /* getDirectory
  34.    load a new gopher directory as indicated by the selected item */
  35.  
  36. static BOOLEAN
  37. getDirectory(gi)
  38. gopherItemP    gi;
  39. {
  40.     int        s;
  41.     gopherDirP    d;
  42.     BOOLEAN        fetchOK;
  43.  
  44.     if (( s = GI_connectWithStatus(gi) ) < 0 ) return FALSE;
  45.  
  46.     writeString(s, vStringValue(&(gi->selector)));
  47.     writeString(s, EOL_STRING);
  48.  
  49.     d = newDir();
  50.  
  51.     if (noCurrentDir()) {
  52.         showStatus("Getting main gopher directory",
  53.             STAT_ROOT, gi->host, gi->port);
  54.     } else {
  55.     showStatus("Getting new directory",
  56.             STAT_DIRECTORY, gi->host, gi->port);
  57.     }
  58.  
  59.     fetchOK = GI_getGopherDir(s, d);
  60.  
  61.     close(s);
  62.  
  63.     if (!removeStatusPanel() ) {
  64.  
  65.         /* someone cancelled as the directory load finished */
  66.  
  67.         freeDir(d);
  68.         return FALSE;
  69.     }
  70.  
  71.     if (! fetchOK ) {
  72.  
  73.         /* failure to load directory */
  74.  
  75.         freeDir(d);
  76.         showError(
  77.             "There seems to be no information in this directory\n");
  78.         return FALSE;
  79.     }
  80.  
  81.     setDirTime(d);
  82.  
  83.  
  84.     d->selectorItem = copyItem(gi);
  85.     
  86.     pushCurrentDir(d);
  87.  
  88.     displayCurrent();
  89.  
  90.     return TRUE;
  91. }
  92.  
  93.  
  94. /* GIDir_init
  95.    initialize directory class - prefix string */
  96.  
  97. void
  98. GIDir_init()
  99. {
  100.     GU_makePrefix(prefixDir,  appResources->prefixDir);
  101.     GU_registerNewType(A_DIRECTORY, &dirSubclass);
  102.  
  103.     return;
  104. }
  105.  
  106.  
  107. /* GIDir_restart
  108.    restart directory class - clear directory stack */
  109.  
  110. void
  111. GIDir_restart()
  112. {
  113.     clearDirStack();
  114.  
  115.     return;
  116. }
  117.  
  118.  
  119. /* GIDir_process
  120.    process a directory selection */
  121.  
  122. BOOLEAN
  123. GIDir_process(gi)
  124. gopherItemP    gi;
  125. {
  126.     BOOLEAN    result;
  127.  
  128.     result = getDirectory(gi);
  129.  
  130.     return result;
  131. }
  132.